<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>居民区项目活动信息</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script charset="utf-8" src="/djzx/js/kindeditor-4.1.10/kindeditor.js"></script>
<script charset="utf-8" src="/djzx/js/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script type="text/javascript" charset="utf-8" src="/djzx/js/myJs2.js"></script>
<script language="javascript">

$(document).ready(function(){
	$('#projectKey').val('${projectKey}');
});

function goback(){
	var editFrom = ${editFrom };
	var timeKey = $('#timeKey').val();
	var projectTimeKey =  $('#projectTimeKey').val();
	if(editFrom == 1){
		window.location.href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey=" + projectTimeKey;
	}else if(editFrom == 2){
		window.location.href="/djzx/CommunityProjectAction!toShowProjectActivity.action?communityProjectActivity.timeKey="
								+ timeKey + "&communityProject.timeKey=" + projectTimeKey;
	}else{
		
	}
}

function updateProjectActivity(){
	var timeKey = $.trim($('#timeKey').val());
	var name = $.trim($('#name').val());
	editor6.sync();
	var content = $.trim($('#content').val());
	editor7.sync();
	var situation = $.trim($('#situation').val());
	var projectKey = $.trim($('#projectKey').val());
	
	if(name==""){
		alert("活动名称不能为空");
		return;
	}
	
	if(content==""){
		alert("活动内容不能为空");
		return;
	}
	if(situation==""){
		alert("活动情况不能为空");
		return;
	}
	
	var fd = new FormData();
	fd.append('communityProjectActivity.timeKey',timeKey);
	fd.append('communityProjectActivity.name',name);
	fd.append('communityProjectActivity.content',content);
	fd.append('communityProjectActivity.situation',situation);
	fd.append('projectKey',projectKey);
	
	$.ajax({
	    url:"${pageContext.request.contextPath}/CommunityProjectActivityAction!updateProjectActivity.action",
	    type:"POST",
	    data:fd,
	    dataType: "json", 
	    contentType: false, //必须
	    processData: false, //必须
	    success:function(data){
	    	alert(data.message);
			if(data.success){
				var editFrom = ${editFrom };
				var timeKey = $('#timeKey').val();
				if(editFrom == 1){
					window.location.href="/djzx/CommunityProjectActivityAction!getProjectActivityListForPage.action";
				}else if(editFrom == 2){
					window.location.href="/djzx/CommunityProjectActivityAction!toShowProjectActivity.action?communityProjectActivity.timeKey=" + timeKey;
				}else{
					
				}
			}
	    }
	}); 
}

</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">编辑项目活动</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<input type="hidden" name="timeKey" id="timeKey" value="${communityProjectActivity.timeKey }" />
<input type="hidden" name="projectTimeKey" id="projectTimeKey" value="${communityProject.timeKey }" />
<table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
        <td width="120" height="24" class="td_form01">活动名称</td>
        <td nowrap class=td_form02>
        	<input type="text" name="name" id="name" size="30" value="${communityProjectActivity.name }" />
        </td>
      </tr>
      <tr>
        <td width="120" class="td_form01">活动内容</td>
        <td nowrap class=td_form02 colspan="3">
        	<textarea style="width:300px;height:200px" name="content" id="content">${communityProjectActivity.content}</textarea>
		</td>
      </tr>
      <tr>
        <td width="120" class="td_form01">活动情况</td>
        <td nowrap class=td_form02 colspan="3">
        	<textarea style="width:300px;height:200px" name="situation" id="situation">${communityProjectActivity.situation}</textarea>
		</td>
      </tr>
      <tr>
        <td class="td_form01">所属项目</td>
        <td nowrap class=td_form02>
        	<select name="projectKey" id="projectKey">
        	  <s:iterator value="communityProjectList" var="c" status="statu">
        	  	<option value="${c.timeKey }">${c.name }</option>
        	  </s:iterator>
      		</select>
        </td>
      </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><input name="Submit2" type="button" class="buttonface" value="  保存  " onClick="updateProjectActivity()">
    <input name="Submit" type="button" class="buttonface" value="  返回  "  onClick="goback()"></td>
  </tr>
</table>
<br>
</body>
</html>